我們想要看到更多監控稽核日誌,來幫我們找到異常問題
使用auditctl,查看一下上一章Pkexec提權的日誌
增加規則,設定檔路徑/etc/audit/rules.d/audit.rules
-w /usr/bin/pkexec -p x -k pkexec_monitor
本機主機日誌 /var/log/audit/audit.log
type=SYSCALL msg=audit(1728481695.022:165): arch=c000003e syscall=59 success=yes exit=0 a0=561ca89f9162 a1=7ffe04ef4e48 a2=7ffe04ef4e58 a3=3 items=2 ppid=3438 pid=5033 auid=1000 uid=1000 gid=1000 euid=0 suid=0 fsuid=0 egid=1000 sgid=1000 fsgid=1000 tty=pts0 ses=4 comm="pkexec" exe="/usr/bin/pkexec" key="pkexec_monitor"
type=EXECVE msg=audit(1728481695.022:165): argc=0 a0=".pkexec"
type=CWD msg=audit(1728481695.022:165): cwd="/home/training/Desktop"
type=PATH msg=audit(1728481695.022:165): item=0 name="/usr/bin/pkexec" inode=4195233 dev=08:01 mode=0104755 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0
type=PATH msg=audit(1728481695.022:165): item=1 name="/lib64/ld-linux-x86-64.so.2" inode=4980742 dev=08:01 mode=0100755 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0
type=PROCTITLE msg=audit(1728481695.022:165): proctitle="(null)"
pkexec --user root su
本機主機日誌 /var/log/audit/audit.log
type=SYSCALL msg=audit(1728486350.356:298): arch=c000003e syscall=59 success=yes exit=0 a0=5650eaa960f0 a1=5650ea967260 a2=5650eaa79c40 a3=8 items=2 ppid=3438 pid=5781 auid=1000 uid=1000 gid=1000 euid=0 suid=0 fsuid=0 egid=1000 sgid=1000 fsgid=1000 tty=pts0 ses=4 comm="pkexec" exe="/usr/bin/pkexec" key="pkexec_monitor"
type=EXECVE msg=audit(1728486350.356:298): argc=4 a0="pkexec" a1="--user" a2="root" a3="su"
type=CWD msg=audit(1728486350.356:298): cwd="/home/training/Desktop"
type=PATH msg=audit(1728486350.356:298): item=0 name="/usr/bin/pkexec" inode=4195233 dev=08:01 mode=0104755 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0
type=PATH msg=audit(1728486350.356:298): item=1 name="/lib64/ld-linux-x86-64.so.2" inode=4980742 dev=08:01 mode=0100755 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0
type=PROCTITLE msg=audit(1728486350.356:298): proctitle=706B65786563002D2D7573657200726F6F74007375
type=USER_AUTH msg=audit(1728486355.528:299): pid=5784 uid=1000 auid=1000 ses=3 msg='op=PAM:authentication acct="training" exe="/usr/lib/policykit-1/polkit-agent-helper-1" hostname=? addr=? terminal=? res=success'
type=USER_ACCT msg=audit(1728486355.528:300): pid=5784 uid=1000 auid=1000 ses=3 msg='op=PAM:accounting acct="training" exe="/usr/lib/policykit-1/polkit-agent-helper-1" hostname=? addr=? terminal=? res=success'
type=USER_START msg=audit(1728486355.552:301): pid=5781 uid=1000 auid=1000 ses=4 msg='op=PAM:session_open acct="root" exe="/usr/bin/pkexec" hostname=training-virtual-machine addr=? terminal=pts/0 res=success'
type=USER_AUTH msg=audit(1728486355.556:302): pid=5781 uid=0 auid=1000 ses=4 msg='op=PAM:authentication acct="root" exe="/bin/su" hostname=? addr=? terminal=/dev/pts/0 res=success'
type=USER_ACCT msg=audit(1728486355.556:303): pid=5781 uid=0 auid=1000 ses=4 msg='op=PAM:accounting acct="root" exe="/bin/su" hostname=? addr=? terminal=/dev/pts/0 res=success'
type=CRED_ACQ msg=audit(1728486355.556:304): pid=5781 uid=0 auid=1000 ses=4 msg='op=PAM:setcred acct="root" exe="/bin/su" hostname=? addr=? terminal=/dev/pts/0 res=success'
type=USER_START msg=audit(1728486355.568:305): pid=5781 uid=0 auid=1000 ses=4 msg='op=PAM:session_open acct="root" exe="/bin/su" hostname=? addr=? terminal=/dev/pts/0 res=success'
type=USER_ROLE_CHANGE msg=audit(1728486355.568:306): pid=5787 uid=0 auid=1000 ses=4 msg='op=su acct="root" exe="/bin/su" hostname=localhost addr=127.0.0.1 terminal=/dev/pts/0 res=success'
實作配置audit記錄機制 Linux核心監控不漏勾
https://www.netadmin.com.tw/netadmin/zh-tw/technology/87B0B07EEFE849A1A898E6A288C73E9A
IR - SOC162-112 - Pwnkit (CVE-2021-4034) Detected - Auditd (pkexec)
https://www.youtube.com/watch?v=6AAZM1mZgyM
Hunting for Persistence in Linux (Part 1): Auditd, Sysmon, Osquery (and Webshells)
https://pberba.github.io/security/2021/11/22/linux-threat-hunting-for-persistence-sysmon-auditd-webshell/
使用稽核稽核稽核稽核稽核 Oracle Linux
https://docs.oracle.com/zh-tw/learn/ol-auditd/#temporarily-enable-and-disable-auditing
Linux auditd主机系统安全审计服务配置技术方案
https://blog.csdn.net/watermelonbig/article/details/124154640
linux audit审计(7-1)--读懂audit日志
https://www.cnblogs.com/xingmuxin/p/8807774.html
Linux auditd for Threat Detection [Part 1]
https://izyknows.medium.com/linux-auditd-for-threat-detection-d06c8b941505
補充 (ChatGPT)